﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/MasterPage.master"
    AutoEventWireup="true" CodeFile="Covers.aspx.cs" Inherits="Items_Covers" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <telerik:RadGrid ID="rgCovers" runat="server" AllowPaging="True" AutoGenerateColumns="False"
        DataSourceID="sdsCovers" GridLines="None" Width="60%" AllowAutomaticInserts="true"
        AllowAutomaticDeletes="true" AllowAutomaticUpdates="true">
        <HeaderContextMenu EnableTheming="True">
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
        </HeaderContextMenu>
        <MasterTableView DataSourceID="sdsCovers" AutoGenerateColumns="false" EditFormSettings-EditColumn-ButtonType="ImageButton"
            EditFormSettings-EditColumn-CancelText="Прекрати" EditFormSettings-EditColumn-UpdateText="Обнови"
            DataKeyNames="CoverID" Caption="Калъфки" EditFormSettings-EditColumn-InsertText="Въведи"
            EditMode="EditForms" AllowPaging="true" PagerStyle-Mode="NextPrevAndNumeric"
            CommandItemDisplay="Top" CommandItemSettings-RefreshText="Обнови" CommandItemSettings-AddNewRecordText="Добави нов запис"
            EditFormSettings-ColumnNumber="2" Name="Covers">
            <CommandItemSettings AddNewRecordText="Добави нов запис" RefreshText="Обнови" />
            <DetailTables>
                <telerik:GridTableView Caption="Платове" AllowSorting="false" DataKeyNames="FinalCoverID"
                    AllowAutomaticDeletes="true" AllowAutomaticInserts="true" Name="Bufabs" DataSourceID="sdsFinalCovers"
                    CommandItemDisplay="Top" EditFormSettings-EditColumn-ButtonType="ImageButton"
                    EditFormSettings-EditColumn-CancelText="Прекрати" EditFormSettings-EditColumn-UpdateText="Обнови"
                    EditFormSettings-EditColumn-InsertText="Въведи" CommandItemSettings-AddNewRecordText="Добави плат"
                    CommandItemSettings-RefreshText="Обнови" Width="70%">
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="CoverID" MasterKeyField="CoverID" />
                    </ParentTableRelation>
                    <CommandItemSettings AddNewRecordText="Добави плат" RefreshText="Обнови"></CommandItemSettings>
                    <RowIndicatorColumn>
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn>
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </ExpandCollapseColumn>
                    <Columns>
                        <telerik:GridDropDownColumn DataField="MaterialID" HeaderText="Описание на плат"
                            DropDownControlType="RadComboBox" DataSourceID="ldsMaterials" ListTextField="Description"
                            ListValueField="MaterialID" UniqueName="colMaterial" ItemStyle-Width="90%">
                        </telerik:GridDropDownColumn>
                        <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" Text="Изтрий"
                            HeaderText="Изтрий" UniqueName="columnDelete" ConfirmText="Сигурни ли сте, че искате да изтриете записа?"
                            ItemStyle-Width="10%">
                            <ItemStyle Width="10%"></ItemStyle>
                        </telerik:GridButtonColumn>
                    </Columns>
                    <EditFormSettings>
                        <EditColumn ButtonType="ImageButton" CancelText="Прекрати" UpdateText="Обнови" InsertText="Въведи">
                        </EditColumn>
                    </EditFormSettings>
                </telerik:GridTableView>
            </DetailTables>
            <Columns>
                <telerik:GridBoundColumn DataField="Code" HeaderText="Код" EditFormColumnIndex="0" />
                <telerik:GridBoundColumn DataField="NameBG" HeaderText="Име BG" EditFormColumnIndex="0" />
                <telerik:GridBoundColumn DataField="NameEN" HeaderText="Име EN" EditFormColumnIndex="0" />
                <telerik:GridNumericColumn DataField="EXW" HeaderText="EXW" Visible="false" EditFormColumnIndex="1" />
                <telerik:GridNumericColumn DataField="DDU" HeaderText="DDU" Visible="false" EditFormColumnIndex="1" />
                <telerik:GridNumericColumn DataField="Count" HeaderText="Брой" Visible="false" EditFormColumnIndex="1"
                    DataType="System.Int32" />
                <telerik:GridNumericColumn DataField="Expense" HeaderText="Разход" Visible="false"
                    EditFormColumnIndex="1" DataType="System.Decimal" />
                <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Edit" Text="Редактирай"
                    UniqueName="columnEdit">
                </telerik:GridButtonColumn>
                <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" Text="Изтрий"
                    UniqueName="columnDelete" ConfirmText="Сигурни ли сте, че искате да изтриете записа? Така ще изтриете и историята за този запис!">
                </telerik:GridButtonColumn>
            </Columns>
            <RowIndicatorColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <EditFormSettings ColumnNumber="3">
                <EditColumn ButtonType="ImageButton" CancelText="Прекрати" UpdateText="Обнови" InsertText="Въведи">
                </EditColumn>
            </EditFormSettings>
            <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
        </MasterTableView>
        <FilterMenu EnableTheming="True">
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
        </FilterMenu>
        <ClientSettings>
            <Selecting AllowRowSelect="true" />
        </ClientSettings>
    </telerik:RadGrid>
    <asp:LinqDataSource ID="ldsMaterials" runat="server" ContextTypeName="ItemsDataContext"
        TableName="Materials" Where="IsBufab == @IsBufab">
        <WhereParameters>
            <asp:Parameter DefaultValue="false" Name="IsBufab" Type="Boolean" />
        </WhereParameters>
    </asp:LinqDataSource>
    <asp:SqlDataSource ID="sdsCovers" runat="server" ConnectionString="<%$ ConnectionStrings:KonturConnectionString %>"
        DeleteCommand="usp_CoversDelete" DeleteCommandType="StoredProcedure" InsertCommand="usp_CoversCreate"
        InsertCommandType="StoredProcedure" SelectCommand="usp_CoversSelect" SelectCommandType="StoredProcedure"
        UpdateCommand="usp_CoversUpdate" UpdateCommandType="StoredProcedure">
        <DeleteParameters>
            <asp:Parameter Name="CoverID" Type="Int32" />
        </DeleteParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="sdsFinalCovers" runat="server" ConnectionString="<%$ ConnectionStrings:KonturConnectionString %>"
        DeleteCommand="usp_FinalCoversDelete" DeleteCommandType="StoredProcedure" InsertCommand="usp_FinalCoversCreate"
        InsertCommandType="StoredProcedure" SelectCommand="usp_FinalCoversSelect" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:Parameter Name="CoverID" Type="Int32" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="FinalCoverID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="CoverID" Type="Int32" />
            <asp:Parameter Name="MaterialID" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgCovers">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgCovers" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
</asp:Content>
